﻿/// <summary>
/// 简单的单例类
/// </summary>
public abstract class SingletonBase<T> where T : SingletonBase<T>, new()
{
    private static T m_Instance;
    /// <summary>
    /// 静态单例
    /// </summary>
    public static T instance
    {
        get
        {
            if (m_Instance == null)
            {
                m_Instance = new T();
                m_Instance.Init();
            }
            return m_Instance;
        }
    }

    private void Init()
    {
        OnInit();
    }

    /// <summary>
    /// 初始化
    /// 在instance生成时调用
    /// </summary>
    protected virtual void OnInit() { }
}